import axios from 'axios'
const apiUrl = process.env.API
const api = {
  test: () => {
    console.log(apiUrl)
    return axios.get(apiUrl + 'dataview/index')
  },

  project1Index: () => {
    return axios.post(apiUrl + 'web/culture/index')
  },

  getHeart: () => {
    return axios.post(apiUrl + 'web/jt/index')
  },

  chooseSchool: (type, cid) => {
    return axios({
      method: 'post',
      url: apiUrl + 'web/list',
      data: {
        type: type,
        cid: cid
      }
    })
  },

  getChinaId: () => {
    return axios.post(apiUrl + 'web/jt/love')
  },

  project3Index: () => {
    return axios.post(apiUrl + 'web/science/index')
  },

  project4Index: () => {
    return axios.post(apiUrl + 'web/front/index')
  },

  articleList: (type, id) => {
    return axios({
      method: 'post',
      url: apiUrl + 'web/list',
      data: {
        type: type,
        id: id
      }
    })
  },

  articleDetail: (id) => {
    return axios({
      method: 'post',
      url: apiUrl + 'web/article/detail',
      data: {
        id: id
      }
    })
  },

  // 登录
  login: (code) => {
    return axios({
      method: 'post',
      url: apiUrl + 'ja/login',
      data: {
        code: code
      }
    })
  },

  // 登出
  logout: () => {
    return axios.post(apiUrl + 'ja/logout')
  },

  // 个人中心
  home: (code) => {
    return axios({
      method: 'post',
      url: apiUrl + 'home',
      data: {
        id: code
      }
    })
  },

  // 查看问卷 调用此接口时，如果用户是第一次调用，则为学生分配问卷。
  formDetail: (code) => {
    return axios({
      method: 'post',
      url: apiUrl + 'exam/detail',
      data: {
        id: code
      }
    })
  },

  // 提交问卷
  formSubmit: (id, answers, openanswer) => {
    return axios({
      method: 'post',
      url: apiUrl + 'exam/submit',
      data: {
        id: id,
        answers: answers,
        openanswer: openanswer
      }
    })
  },

  // 重置用户答卷
  formReset: (id) => {
    return axios({
      method: 'post',
      url: apiUrl + 'exam/reset',
      data: {
        id: id
      }
    })
  }
}

export default api
